package org.budo.elasticsearch.repository;

import org.budo.graph.annotation.SpringGraph;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.springframework.data.domain.Page;
import org.springframework.data.elasticsearch.core.SearchResultMapper;
import org.springframework.data.elasticsearch.core.aggregation.AggregatedPage;
import org.springframework.data.elasticsearch.core.query.SearchQuery;

/**
 * @author limingwei
 */
public interface BudoElasticsearchRepository {
    SearchRequestBuilder prepareSearch(String... indices);

    void clearScroll(String scrollId);

    void setSearchTimeout(String searchTimeout);

    <T> Page<T> scroll(String scrollId, long scrollTimeInMillis, SearchResultMapper mapper);

    String scan(SearchQuery searchQuery, long scrollTimeInMillis, boolean noFields);

    @SpringGraph
    <T> AggregatedPage<T> queryForPage(SearchQuery searchQuery, Class<T> clazz, SearchResultMapper mapper);
}